

#import "ZGL24ClassifiedCell.h"
#import "ZGL24ClassifiedModel.h"
@interface ZGL24ClassifiedCell()
@property(nonatomic, retain)UIView *background;
@property(nonatomic, retain)UIButton *button1;
@property(nonatomic, retain)UIButton *button2;
@property(nonatomic, retain)UILabel *tname;
@property(nonatomic, retain)UILabel *subnum;
@property(nonatomic, retain)UILabel *title;
@property(nonatomic, retain)UILabel *digest;
@property(nonatomic, retain)UILabel *line;
@property(nonatomic, retain)UIImageView *img;
@end
@implementation ZGL24ClassifiedCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        _background = [[UIView alloc]init];
        _background.layer.shadowColor = [UIColor blackColor].CGColor;
        _background.layer.shadowOffset = CGSizeMake(2,2);
        _background.layer.shadowOpacity = 0.8;
        _background.layer.shadowRadius = 4;
        [self.contentView addSubview:_background];
        
        _button1 = [UIButton buttonWithType:UIButtonTypeCustom];
        [_button1 addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
        [_background addSubview:_button1];
        _button2 = [UIButton buttonWithType:UIButtonTypeCustom];
        [_button2 addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
        [_background addSubview:_button2];
        
        _tname = [[UILabel alloc]init];
        [_button1 addSubview:_tname];
        
        _subnum = [[UILabel alloc]init];
        _subnum.textColor = [UIColor lightGrayColor];
        _subnum.font = [UIFont systemFontOfSize:10];
        [_button1 addSubview:_subnum];
        
        _title = [[UILabel alloc]init];
        [_button2 addSubview:_title];
        
        _digest = [[UILabel alloc]init];
        _digest.textColor = [UIColor lightGrayColor];
        _digest.font = [UIFont systemFontOfSize:10];
        [_button2 addSubview:_digest];
        
        _line = [[UILabel alloc]init];
        _line.backgroundColor = [UIColor lightGrayColor];
        [self.background addSubview:_line];
        
        _img = [[UIImageView alloc]init];
        [_button1 addSubview:_img];
    }
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    self.backgroundColor = backColor;
    _background.backgroundColor = foreColor;
    self.tname.textColor = artiColor;
    _title.textColor = artiColor;
    _background.frame = CGRectMake(12*ScaleX, 12*ScaleX, 350*ScaleX, 140*ScaleX);
    _button1.frame = CGRectMake(1, 1, 348*ScaleX, 68*ScaleX);
    _button2.frame = CGRectMake(1, 71*ScaleX, 348*ScaleX, 68*ScaleX);
    _tname.frame = CGRectMake(65*ScaleX, 15*ScaleX, 250*ScaleX, 20*ScaleX);
    _subnum.frame = CGRectMake(65*ScaleX, 40*ScaleX, 100*ScaleX, 20*ScaleX);
    _title.frame = CGRectMake(15*ScaleX, 10*ScaleX, 320*ScaleX, 25*ScaleX);
    _digest.frame = CGRectMake(15*ScaleX, 40*ScaleX, 320*ScaleX, 20*ScaleX);
    _line.frame = CGRectMake(15*ScaleX, 70*ScaleX, 320*ScaleX, 1);
    _img.frame = CGRectMake(15*ScaleX, 15*ScaleX, 45*ScaleX, 45*ScaleX);
}

- (void)setMod:(ZGL24ClassifiedModel *)mod{
    _mod = mod;
    _height = 155*ScaleX;
    _tname.text = mod.tname;
    _subnum.text = mod.subnum;
    _title.text = mod.title;
    _digest.text = mod.digest;

    //NSString *str = [NSString stringWithFormat:@"http://s.cimg.163.com/pi/img3.cache.netease.com/m/newsapp/topic_icons/%@.png.201x2147483647.75.auto.webp", mod.tid];

}

- (void)click:(UIButton *)button{
    if (button.frame.origin.y == 1) {
        self.buttonClick(self.mod.tid, @"tid", self.mod.tname);
    }else{
        self.buttonClick(self.mod.docid, @"docid", @"");
    }
}

@end
